package net.csdn.business.common.feign.oauth2;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.common.constant.ServiceNameConstants;
import net.csdn.business.common.domain.request.oauth.*;
import net.csdn.business.common.domain.vo.oauth.OauthClientInfoVo;
import net.csdn.business.common.domain.vo.oauth.OauthStatVO;
import net.csdn.business.common.feign.oauth2.config.AuthFeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;


/**
 * @Desc: auth服务提供应用管理接口
 * @Author: zhangyalei
 * @Date: 2022/12/19 13:51
 */
@FeignClient(value = ServiceNameConstants.ATOMGIT_AUTH_SERVICE,contextId = ServiceNameConstants.ATOMGIT_AUTH_CLIENT_CONTEXT_ID , configuration = AuthFeignConfiguration.class)
public interface AuthClientInfoFeignClient {


	/**
	 * @Desc: 分页查询我创建的oauth应用列表
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@PostMapping("/api/v1/client/myList")
	public Page<OauthClientInfoVo> findMyPageList(@RequestBody OauthClientInfoQuery query);


	/**
	 * @Desc: 分页查询我已经授权的oauth应用列表
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@PostMapping("/api/v1/client/authList")
	public Page<OauthClientInfoVo> findAuthorizeList(@RequestBody OauthClientInfoQuery query);


	/**
	 * @Desc: 根据clientId查询oauth应用信息
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@GetMapping("/api/v1/client/{clientId}")
	public OauthClientInfoVo getClientByClientId(@PathVariable("clientId") String clientId,@RequestParam("isWithSecret") Boolean isWithSecret);



	/**
	 * @Desc: 新增client
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@PostMapping("/api/v1/client/addClient")
	public String addClient(@RequestBody NewOauthClientInfoDTO params);


	/**
	 * @Desc: 更新client
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@PostMapping("/api/v1/client/updateClient")
	public Integer updateClient(@RequestBody UpdateOauthClientInfoDTO params);


	/**
	 * @Desc: client重新生成密钥
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@PostMapping("/api/v1/client/generateSecret")
	public String generateSecret(@RequestBody NewOauthClientSecretDTO params);

	/**
	 * @Desc: 根据clientId删除应用
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@PostMapping("/api/v1/client/deleteByClientId")
	public Integer deleteByClientId(@RequestParam("clientId")String clientId);


	/**
	 * @Desc: 根据tokenId撤销用户对某个应用的授权
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@PostMapping("/api/v1/client/revoke")
	public Integer revoke(@RequestBody OauthRevokeDTO params);


	/**
	 * @Desc: 根据clientId撤销所有用户的授权
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@PostMapping("/api/v1/client/revokeAll")
	public Integer revokeAll(@RequestBody OauthRevokeAllDTO params);

	/**
	 * @Desc: 根据clientId查询应用的授权记录统计信息
	 * @Author: zhangyalei
	 * @Date: 2023/1/11 15:18
	 */
	@GetMapping("/api/v1/client/authStat/{clientId}")
	public OauthStatVO authStat(@PathVariable("clientId")String clientId);

}
